# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=cura
# uranium and curaengine packages must be updated in sync with this verion number
# py3-pynest2d should be checked as well, but the version is not always in sync
pkgver=4.13.1
pkgrel=0
pkgdesc="3D printer / slicing GUI built on top of the Uranium framework"
url="https://ultimaker.com/software/ultimaker-cura"
arch="noarch !ppc64le !x86 !armhf !riscv64" # ppc64le: no py3-keyring
# x86: no curaengine
# armhf: no uranium, qt5-qtquickcontrols, qt5-qtquickcontrols2, qt5-qtgraphicaleffects
# riscv64: no uranium
license="LGPL-3.0-or-later"
# add cura-binary-data to depends when packaged
depends="
	curaengine
	uranium
	py3-keyring
	py3-pynest2d
	py3-requests
	py3-zeroconf
	qt5-qtquickcontrols
	qt5-qtquickcontrols2
	qt5-qtgraphicaleffects
	"
makedepends="samurai cmake gettext gettext-dev" # needs msginit from gettext
checkdepends="py3-pytest"
subpackages="$pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/Ultimaker/Cura/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/Cura-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DCURA_VERSION=$pkgver \
		-DURANIUM_DIR=/usr/share/uranium \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DGETTEXT_MSGINIT_EXECUTABLE=msginit \
		-DCURA_BINARY_DATA_DIRECTORY=/usr/share/cura \
		-DCMAKE_BUILD_TYPE=minsizerel
	cmake --build build
}

check() {
	# useless code style test with another dependency
	sed -i "/add_test(code-style/d" build/CTestTestfile.cmake

	ctest --output-on-failure --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# don't ever send any user or print info through the internet to Ultimaker
	rm -rf "$pkgdir/usr/lib/cura/plugins/SliceInfoPlugin"

	install -d "$pkgdir"/usr/share/locale
	mv "$pkgdir"/usr/share/cura/resources/i18n/* "$pkgdir"/usr/share/locale/
}

sha512sums="
6483fd6312bd2181cc812bce78aadc7e8532ecf292f09c75ce5e7870f7efddd63e84315ab40eb73c775b15c2ed2ce7fc804fcbefb73b3d8aaac77d8b22f0cbd0  cura-4.13.1.tar.gz
"
